package vo;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@NamedQueries({ 
	@NamedQuery(name = "UserTopic.findAll", query = "select ut from UserTopic ut"),
	@NamedQuery(name = "UserTopic.findByUserId", query = "select ut from UserTopic ut where user.id=?"),
	@NamedQuery(name = "UserTopic.findByTopicId", query = "select ut from UserTopic ut where topic.id=?"),
	@NamedQuery(name = "UserTopic.findByTopicIdUserRole", query = "select ut from UserTopic ut where topic.id=? and user.userGroup.role='user'"),
	@NamedQuery(name = "UserTopic.findNonSubUsers", query = "select ut from UserTopic ut where topic.id!=?"),
	@NamedQuery(name = "UserTopic.findByUserIdTopicId", query = "select ut from UserTopic ut where user.id=? and topic.id=?"),
	})
@Table(name = "user_topic")
public class UserTopic extends BaseEntity {

	@JoinColumn(name = "topic_id")
	@ManyToOne(fetch = FetchType.LAZY)
	private Topic topic;
	
	@JoinColumn(name = "user_id")
	@ManyToOne(fetch = FetchType.LAZY)
	private User user;

	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Topic getTopic() {
		return topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}


}
